using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Microsoft.Xna.Framework;

namespace CF.Framework.Engine
{
	public static class GameResources
	{
		private static Dictionary<string, string> texts;

		static GameResources()
		{
			LoadTexts();
		}

		private static void LoadTexts()
		{
			texts = new Dictionary<string, string>();

			foreach (string file in Directory.GetFiles(Path.GetFullPath("Resources\\Texts"), "*.xml", SearchOption.AllDirectories))
			{
				XDocument dom = XDocument.Load(file, LoadOptions.None);
				foreach (XElement node in dom.Document.Root.Elements("item"))
				{
					texts.Add(node.Attribute("key").Value, node.Attribute("value").Value);
				}
			}
		}

		public static string GetDescription(string key)
		{
			if (texts.ContainsKey(key))
			{
				return texts[key];
			}

			return string.Empty;
		}
	}
}
